

<template>
<div class="tourist-home-page">
    <div class="tourist-home-page-top">
    </div>
    <div class="tourist-home-page-bottom">
      <div class="frequently-asked-questions">
        <div class="tip">
          您好,我是您的旅游智能助手,助力智能规划您在全国地区文旅常见问题
        </div>
      </div>
      <div class="cultural-and-tourism-areas">
        <div class="areas-box">
          <div class="tourism-areas-top">
            <div class="tourism-areas-left">

              <div class="tip">
                <img style="width: 18px;height: 14px;margin-left: 4px" src="../../assets/images/notLoggedIn/home_icon.png">
              </div>
              <div class="select-list" @click="handleCommand">
                                                    <div class="title">
                                                      {{selectedItem}}
                                                    </div>
                <div>
                  <img style="width: 16px;height: 16px" src="../../assets/images/notLoggedIn/arrow.png">
                </div>


              </div>


            </div>
<!--            地市-->
            <div class="tourism-areas-right">
              <div class="areas-list" :class="currentClick===index? 'active-select':''" @click="areasClick(item,index)" v-for="(item,index) in tourismList">
                <div class="little-box" :class="currentClick===index? 'active-select-little-box':'un-active-select-little-box'">
                 <span >
                    {{item.cityName}}
                 </span>
                </div>
              </div>
            </div>
          </div>
          <div class="select-list-box" v-if="selected">
            <div v-for="(item,index) in cityList" :key="index" class="select-list-box-group">
              <div class="un-select-list-box-item" @click="cityClick(item)">
                {{item.provinceName}}
              </div>
            </div>
          </div>
          <div class="tourism-areas-bottom">
            <div class="tourism-areas-list">
              <div @click="dataClick(item,index)" class="tour-item" v-for="(item,index) in dataList" :key="index">
                <div class="tour-item-image" :style="{'backgroundImage': `url(${item.image})`}">
                  <div class="content">
<!--                    :class="currentData===index?'tourism-areas-list-active':''"-->
                    <div class="content-box" id="content-box">
                     <div>
                       <div class="name">{{item.categoryName}}</div>
                       <div class="english-name">{{item.englishName}}</div>
                     </div>
                    </div>
                    <div class="children-group">
                      <div class="children-item" v-for="(child,index) in item.informationNames
" :key="index">
                        {{child.landmarkName}}
                      </div>
                    </div>


                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="intelligent-services">
        <div class="intelligent-services-box">
          <div class="intelligent-services-top">
            <div class="tip">
              <img style="width: 18px;height: 14px;margin-left: 4px" src="../../assets/images/notLoggedIn/home_icon.png">
            </div>
            <div class="title">
              智能服务
            </div>
          </div>
          <div class="intelligent-services-bottom">
            <div class="intelligent-services-list">
              <img src="../../assets/images/notLoggedIn/Intelligent%20service1.png">
            </div>
            <div class="intelligent-services-list">
              <img src="../../assets/images/notLoggedIn/Intelligent%20service2.png">
            </div>
            <div class="intelligent-services-list">
              <img src="../../assets/images/notLoggedIn/Intelligent%20service3.png">
            </div>
          </div>
          <div class="btn-box" @click="goLogin">
            <div class="login-btn">
              开始体验
            </div>
          </div>
        </div>
      </div>
    </div>
</div>
</template>
<script setup>
import history from "../../assets/images/notLoggedIn/history_bg.png"
import folklore from "../../assets/images/notLoggedIn/folklore_bg.png"
import celebrities from "../../assets/images/notLoggedIn/Celebrities_bg.png"
import redCultural from "../../assets/images/notLoggedIn/RedCultural_bg.png"
import diet from "../../assets/images/notLoggedIn/Diet_bg.png"
import IFCAT from "../../assets/images/notLoggedIn/IFCAT_bg.png"
import { ref } from 'vue'
import { useRouter } from "vue-router";
import {useTouristHomepageStore} from "@/store/touristHomepage";
import api from "@/service/TouristHomepage";
import {useCulturalSelectionStore} from "@/store/culturalSelection";
const $router = useRouter();
const dataList = ref([])

dataList.value = [
  {
    id: '1',
    categoryName: '历史文旅',
    englishName: 'HISTORY',
    image: history,
  },
    {
      id: '2',
      categoryName: '民俗文旅',
      englishName: 'FOLKLORE',
      image: folklore,
    },
  {
    id: '3',
    categoryName: '名人文旅',
    englishName: 'CELEBRITIES',
    image: celebrities,
  },
  {
    id: '4',
    categoryName: '红色文旅',
    englishName: 'REDCULTURA',
    image: redCultural,
  },
  {
    id: '5',
    categoryName: '饮食文旅',
    englishName: 'DIE',
    image: diet,
  },
  {
    id: '6',
    categoryName: '网红文旅',
    englishName: 'IFCAT',
    image: IFCAT,
  },
]
const currentData = ref(null)
const dataClick = (data,index) => {
  currentData.value = index;
  // 保存store
  useTouristHomepageStore().setTouristCategoryStore(data);
  // 跳转详情页打开空白页
  $router.push({
    name: "touristDetail",
  })



};
const tourismList = ref([])
const currentClick=ref(0)
function areasClick(data,index){
  currentClick.value=index;
  currentClickCityInfo.value=tourismList.value[index];
  // 存入 store，保存当前选择的城市
  useTouristHomepageStore().setTouristCityInfoStore(data);
  getCategoryListApi({divisionCode:data.cityCode})
}
const selected = ref(false);
const cityList=ref([]);
const selectedItem=ref('');
const currentClickProvinceInfo=ref(null);
const currentClickCityInfo=ref(null);
const currentClickInfo=ref(null);
function handleCommand(){
  selected.value=!selected.value;
}
function cityClick(data){
  currentClickInfo.value=data;
  selectedItem.value=data.provinceNickname;
  selected.value=false;
  let obj={
    provinceId:data.provinceId,
    provinceName:data.provinceName,
    provinceCode:data.provinceCode
  }
  getCityListApi(obj)
}
function goLogin(){
  $router.push({ name: "login" });
}
// 请求省份列表
function getProvinceListApi(){
  api.getProvinceList().then((res) => {
    cityList.value=res.data;
    selectedItem.value=res.data[0].provinceNickname;
    currentClickProvinceInfo.value=res.data[0];
    let obj={
      provinceId:res.data[0].provinceId,
      provinceName:res.data[0].provinceName,
      provinceCode:res.data[0].provinceCode
    }
    getCityListApi(obj);
  });
}
// 请求地市列表
function getCityListApi(data){
  api.getCityList(data).then((res) => {
    if(res.data.length>0){
      tourismList.value=res.data;
      // 存储当前地市信息
      useTouristHomepageStore().setTouristCityStore(res.data);
      currentClickCityInfo.value=res.data[0];
      // 存入 store，保存当前选择的城市
      useTouristHomepageStore().setTouristCityInfoStore(res.data[0]);
      getCategoryListApi({divisionCode:res.data[0].cityCode})
    }

  });
}
// 请求旅游信息-文化旅游一级分类类别列表数据
function getCategoryListApi(data){
  api.getCategoryList(data).then((res) => {
    // 把res.data的数据按id一一对应赋值到dataList.value中
    if(res.data.length>0){
      console.log("res.data",res.data);
      console.log("dataList.value",dataList.value);
      dataList.value.forEach((item,index) => {
        res.data.forEach((item1,index1) => {
          if(item.categoryName===item1.categoryName){
            dataList.value[index].informationNames= res.data[index1].informationNames;
            dataList.value[index].divisionCode= res.data[index1].divisionCode;
            dataList.value[index].divisionName= res.data[index1].divisionName;
            dataList.value[index].categoryCode = res.data[index1].categoryCode;

          }
        })
      })
    }else {
      dataList.value.forEach((item,index) => {
            dataList.value[index].informationNames=[];
            dataList.value[index].divisionCode= tourismList.value[currentClick.value].cityCode;
            dataList.value[index].divisionName= tourismList.value[currentClick.value].cityName;
      })
    }


  });
}

onMounted(() => {
  useCulturalSelectionStore().setCulturalSelectionList({})
  getProvinceListApi();
});
</script>
<style scoped lang="scss">
.tourist-home-page{
  width: 100%;
  height: 100%;
  background-image: url("@/assets/images/login/login_bg.png");
  background-repeat: no-repeat;
  background-size: 100% 100%;

  .tourist-home-page-top{
    width: 100%;
    height: 90px;
    background-image: url("@/assets/images/notLoggedIn/top.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
  }
  .tourist-home-page-bottom{
    .frequently-asked-questions{
      height: 120px;
      display: flex;
      justify-content: center;
      align-items: center;
      .tip{
        width: 1097px;
        height: 36px;
        font-family: DingliesongtypefaceRegular;
        font-weight: 400;
        font-size: 36px;
        color: #9B6548;
        text-align: center;
        font-style: normal;
        text-transform: none;
      }
    }
    .cultural-and-tourism-areas{
      display: flex;
      justify-content: center;
.areas-box{
  width: 1460px;
  position: relative;
}
      .tourism-areas-top{
        width: 1460px;
        display: flex;
        padding: 0 35px;
        .tourism-areas-left{

          display: flex;
          align-items: center;
          justify-content: center;
          .tip{
            //  图片垂直居中
            display: flex;
            align-items: center;
            justify-content: center;

          }
          .left-box{
            display: flex;
          }
          .select-list{
            display: flex;
            cursor: pointer;

            .title{
              width: 80px;
              height: 20px;
              font-family: DingliesongtypefaceRegular;
              font-weight: 400;
              font-size: 20px;
              color: #9B6548;
              text-align: left;
              font-style: normal;
              text-transform: none;
            }
          }

        }
        .tourism-areas-right{
          display: flex;
          align-items: center;
          justify-content: center;
          margin-left: 20px;
          .areas-list{
            width: 60px;
            //height: 32px;
            font-family: DingliesongtypefaceRegular;
            font-weight: 400;
            font-size: 14px;
            color: #9B6548;
            text-align: center;
            font-style: normal;
            text-transform: none;
            line-height: 24px;
            cursor: pointer;
          }
          .active-select{
            width: 60px;
            height: 30px;
            border-radius: 4px 4px 4px 4px;
            border: 1px solid #9B6548;
            display: flex;
            align-items: center;
            justify-content: center;
          }
          .active-select-little-box{
            width: 54px;
            height: 24px;
            border-radius: 2px 2px 2px 2px;
            border: 1px solid #9B6548;
          }
          .un-active-select-little-box{
            width: 54px;
            height: 24px;
          }
        }


      }
      .select-list-box{
        box-shadow: 0px 4px 40px 0px rgba(119,81,20,0.16);
        border-radius: 8px 8px 8px 8px;
        border: 2px solid #FFFFFF;
        background-color: #FFFFFF;
position: absolute;
        left: 50px;
        top:40px;
        width: 100px;
        height: 208px;
        z-index: 2000;
        overflow: auto;
        .select-list-box-group{
          display: flex;
          justify-content: center;
          .un-select-list-box-item{
            cursor: pointer;
            width: 60px;
            height: 30px;
            border-radius: 100px 100px 100px 100px;
            color: #AC6117;
            text-align: center;
            margin-top: 16px;
            font-family: DingliesongtypefaceRegular;
            font-weight: 400;
            font-size: 14px;
            line-height: 14px;
            font-style: normal;
            text-transform: none;
            line-height: 30px;
          }
          .un-select-list-box-item:hover{
            cursor: pointer;
            width: 60px;
            height: 30px;
            background: #F5ECE2;
            border-radius: 100px 100px 100px 100px;
            color: #AC6117;
            text-align: center;
            margin-top: 16px;
            font-family: DingliesongtypefaceRegular;
            font-weight: 400;
            font-size: 14px;
            line-height: 14px;
            font-style: normal;
            text-transform: none;
            line-height: 30px;
          }
        }

      }
      .tourism-areas-bottom{
        display: flex;
        justify-content: center;
        margin-top: 30px;
        .tourism-areas-list{
          display: flex;
          gap: 14px;
          .tour-item{
            .tour-item-image{
              width: 220px;
              height: 420px;
              background-repeat: no-repeat;
              background-size: 100% 100%;
              position: relative;
              display: flex;
              .content{
                position: absolute;
                top: 170px;
                margin-left: 10px;
                #content-box :hover{
                  height: 68px;
                  background-image: url("../../assets/images/notLoggedIn/selected.png") !important;
                  background-size: 100% 68px;
                  background-repeat:no-repeat;
                  .english-name{
                    height: 16px !important;
                    background-image: none !important;
                  }
                  .name{
                    height: 24px !important;
                    background-image: none !important;
                  }
                }
                .content-box{
                  height: 68px;
                  cursor: pointer;
                  .name{
                    width: 96px;
                    height: 24px;
                    font-family: DingliesongtypefaceRegular;
                    font-weight: 400;
                    font-size: 24px;
                    color: #9B6548;
                    text-align: left;
                    font-style: normal;
                    text-transform: none;
                    padding-top: 10px;
                    margin-left: 10px;
                  }
                  .english-name{
                    width: 88px;
                    height: 16px;
                    font-family: DingliesongtypefaceRegular;
                    font-weight: 400;
                    font-size: 16px;
                    color: #9B6548;
                    letter-spacing: 6px;
                    text-align: left;
                    font-style: normal;
                    text-transform: none;
                    margin-top: 15px;
                    margin-left: 10px;
                  }
                }
                .tourism-areas-list-active{

                  background-image: url("../../assets/images/notLoggedIn/selected.png");
                  background-size: 100% 68px;
                  background-repeat: no-repeat;
                  .name{
                    padding-top: 10px;
                  }
                }

                .children-group{
                  width: 182px;
                  margin-left: 10px;
                }
                .children-item{

                  font-family: DingliesongtypefaceRegular;
                  font-weight: 400;
                  font-size: 16px;
                  color: #9B6548;
                  line-height: 40px;
                  text-align: left;
                  font-style: normal;
                  text-transform: none;
                }

              }

            }

          }
        }


      }
    }
    .intelligent-services{
      margin-top: 30px;
      display: flex;
      justify-content: center;
      .intelligent-services-box{
        width: 1460px;
        .intelligent-services-top{
          display: flex;
          padding: 0 35px;
          height: 20px;
          font-family: DingliesongtypefaceRegular;
          font-weight: 400;
          font-size: 20px;
          color: #9B6548;
          text-align: left;
          font-style: normal;
          text-transform: none;
          .tip{
          //  图片垂直居中
            display: flex;
            align-items: center;
            justify-content: center;


          }
        }
        .intelligent-services-bottom{
          margin-top: 24px;
          padding: 0 35px;
          display: flex;
          gap: 86px;
        }
      }
    }

  }
  .btn-box{
    margin-top: 20px;
    width: 100%;
    height: 36px;
    border-radius: 0px 0px 0px 0px;
    display: flex;
    justify-content: center;
    .login-btn {
      cursor: pointer;
      background-image: url("@/assets/images/login/login_btn.png");
      background-repeat: no-repeat;
      background-size: 100% 100%;
      width: 186px;
      height: 52px;
      border-radius: 4px 4px 4px 4px;
      font-family: DingliesongtypefaceRegular;
      font-size: 24px;
      letter-spacing: 5px;
      color: #FFFFFF;
      line-height: 52px;
      text-align: center;
      &:hover {
        background-image: url("@/assets/images/login/login_btn_highlight.png");
        background-repeat: no-repeat;
        background-size: 100% 100%;
        width: 186px;
        height: 63px;
        border-radius: 4px 4px 4px 4px;
        font-family: DingliesongtypefaceRegular;
        font-size: 24px;
        letter-spacing: 5px;
        color: #FFFFFF;
        line-height:52px;
        text-align: center;
      }
    }
  }
}
</style>
<style lang="scss">
.el-dropdown-menu {
  width: 100px !important;
  background-color: #FFFFFF;

}
.el-dropdown-menu__item{
  width: 50px;
  justify-content: center;
  color: #AC6117 !important;
}
//选中的样式
/* 修改所有下拉项的悬停样式 */
.el-dropdown-menu__item:not(.is-disabled):hover {
  background-color: #F5ECE2 !important;
}

/* 修改悬停时的字体颜色 */
.el-dropdown-menu__item:hover {
  color: #AC6117 !important;
}

</style>